Column
Center of Las Vegas: 36.1699° N, 115.1398° W. Plotly displayed is surrounds this center by 0.5 degrees longitude and latitude.
=======
>>>>>>> 63202e9a2379c7f7d5f2807943011ecd8f3bbc2f
restaurants %>%
filter(latitude > 35.6699 & latitude < 36.6699) %>%
filter(longitude < -114.6398 & longitude > -115.6398) %>%
plot_ly(x = ~longitude, y = ~latitude, type = "scatter", mode = "markers",
alpha = 0.5,
color = ~stars, hoverinfo = 'text',
text = ~paste(name, " @", neighborhood, "\n", address, "\n", city, ", ", state, postal_code, "\n", stars, "stars on Yelp")) %>%
layout(xaxis = list(title = "Longitude"),
yaxis = list(title = "Latitude"))
<<<<<<< HEAD
=======
Creating a plotly of restaurant locations
Center of Las Vegas: 36.1699° N, 115.1398° W. Plotly displayed is surrounds this center by 0.5 degrees longitude and latitude.
restaurants %>%
filter(latitude > 35.6699 & latitude < 36.6699) %>%
filter(longitude < -114.6398 & longitude > -115.6398) %>%
plot_ly(x = ~longitude, y = ~latitude, type = "scatter", mode = "markers",
alpha = 0.5,
color = ~stars, hoverinfo = 'text',
text = ~paste(name, " @", neighborhood, "\n", address, "\n", city, ", ", state, postal_code, "\n", stars, "stars on Yelp")) %>%
layout(xaxis = list(title = "Longitude"),
yaxis = list(title = "Latitude"))
Creating a plotly of open and closed restaurant compared to their rating on Yelp
restaurants %>%
mutate(stars = if_else(stars == 1, "1",
if_else(stars == 1.5, "1.5",
if_else(stars == 2, "2",
if_else(stars == 2.5, "2.5",
if_else(stars == 3, "3",
if_else(stars == 4, "4",
if_else(stars == 4.5, "4.5", "5"))))))),
review_count = as.numeric(review_count)) %>%
group_by(stars) %>%
plot_ly(x = ~stars, y = ~review_count, color = ~stars, type = "bar", colors = "Set3") %>%
layout(xaxis = list(title = "Stars"),
yaxis = list(title = "Number of Reviews"))
Plots of Restaurants
popular <- categories %>%
filter(category == "Restaurants" | category == "Food") %>%
distinct(business_id) %>%
left_join(categories, by = "business_id") %>%
filter(category %in% c("Bars", "Breakfast & Brunch", "Chinese", "Italian", "Mexican", "Chicken Wings", "Salad", "Sushi Bars", "Pizza", "Steakhouses", "Fast Food"))
restaurants %>%
select(business_id, neighborhood) %>%
inner_join(popular) %>%
distinct() %>%
group_by(neighborhood, category) %>%
tally() %>%
plotly::plot_ly(x = ~neighborhood, y = ~n, type = 'bar', color = ~category, hoverinfo = 'text',
text = ~paste(neighborhood, " has ",
n, " ", category, " restaurants.")) %>%
layout(yaxis = list(title = "Restaurants"), xaxis = list(title = "", tickangle = -45), barmode = 'stack')
## Joining, by = "business_id"
## Warning in RColorBrewer::brewer.pal(N, "Set2"): n too large, allowed maximum for palette Set2 is 8
## Returning the palette you asked for with that many colors
## Warning in RColorBrewer::brewer.pal(N, "Set2"): n too large, allowed maximum for palette Set2 is 8
## Returning the palette you asked for with that many colors
restaurants %>%
inner_join(popular) %>%
select(stars, category) %>%
group_by(category) %>%
summarise(avg_stars = mean(stars)) %>%
arrange(desc(avg_stars)) %>%
knitr::kable()
## Joining, by = "business_id"
| Sushi Bars |
3.803977 |
| Steakhouses |
3.791096 |
| Salad |
3.742958 |
| Breakfast & Brunch |
3.626866 |
| Bars |
3.600000 |
| Italian |
3.558333 |
| Mexican |
3.537471 |
| Chinese |
3.372047 |
| Pizza |
3.369863 |
| Chicken Wings |
3.174497 |
| Fast Food |
2.855289 |
Geographic Plot by Categories
restaurants %>%
inner_join(popular) %>%
plot_ly(x = ~longitude, y = ~latitude, type = "scatter", mode = "markers",
alpha = 0.9,
color = ~category, hoverinfo = 'text',
text = ~paste(name, " @", neighborhood, "\n", address, "\n", city, ", ", state, postal_code, "\n", stars, "star", category, "on Yelp.")) %>%
layout(xaxis = list(title = "Longitude"),
yaxis = list(title = "Latitude"))
## Joining, by = "business_id"
## Warning in RColorBrewer::brewer.pal(N, "Set2"): n too large, allowed maximum for palette Set2 is 8
## Returning the palette you asked for with that many colors
## Warning in RColorBrewer::brewer.pal(N, "Set2"): n too large, allowed maximum for palette Set2 is 8
## Returning the palette you asked for with that many colors
<<<<<<< HEAD
>>>>>>> 63202e9a2379c7f7d5f2807943011ecd8f3bbc2f
=======
STATS WOO!
Do star ratings vary by category type?
aov_stars_by_category <- restaurants %>%
inner_join(popular) %>%
aov(stars ~ category, data = .) %>%
broom::glance()
## Joining, by = "business_id"
Do stars vary by neighborhood?
aov_stars_by_neighborhood <- restaurants %>%
inner_join(popular) %>%
aov(stars ~ neighborhood, data = .) %>%
broom::glance()
## Joining, by = "business_id"
Are stars and review counts correlated?
rsq_stars_review_count <- restaurants %>%
select(review_count, stars) %>%
lm(stars ~ review_count, data = .) %>%
broom::glance()
>>>>>>> 33f12023d833321d738b1906b34cb4b704c4914e
Column
Plots of Restaurants
popular <- categories %>%
filter(category == "Restaurants" | category == "Food") %>%
distinct(business_id) %>%
left_join(categories, by = "business_id") %>%
filter(category %in% c("Bars", "Breakfast & Brunch", "Chinese", "Italian", "Mexican", "Chicken Wings", "Salad", "Sushi Bars", "Pizza", "Steakhouses", "Fast Food"))
restaurants %>%
select(business_id, neighborhood) %>%
inner_join(popular) %>%
distinct() %>%
group_by(neighborhood, category) %>%
tally() %>%
plotly::plot_ly(x = ~neighborhood, y = ~n, type = 'bar', color = ~category, hoverinfo = 'text',
text = ~paste(neighborhood, " has ",
n, " ", category, " restaurants.")) %>%
layout(yaxis = list(title = "Restaurants"), xaxis = list(title = "", tickangle = -45), barmode = 'stack')
Geographic Plot by Categories
restaurants %>%
inner_join(popular) %>%
plot_ly(x = ~longitude, y = ~latitude, type = "scatter", mode = "markers",
alpha = 0.9,
color = ~category, hoverinfo = 'text',
text = ~paste(name, " @", neighborhood, "\n", address, "\n", city, ", ", state, postal_code, "\n", stars, "star", category, "on Yelp.")) %>%
layout(xaxis = list(title = "Longitude"),
yaxis = list(title = "Latitude"))